キーエンス2020 B - Robot Arms
提出
TLE/WA
code: python
n = int(input())
x = []
l = []
for i in range(n):
x.append(X)
l.append(L)
arms = []
for i in range(n):
arms_l = [int(i) for i in range(xi, xi + li)] + [int(i) for i in range(xi - 1, xi - li, -1)] arms.append(sorted(arms_l))
ans = n
for i in range(n-1):
ans -= 1
print(ans)
解答
code: python
n = int(input())
arm = []
for x_l in xl:
arm.append((x_l0 - x_l1, x_l0 + x_l1)) arm = sorted(arm, key=lambda x: x1) res = 0
tmp = -1e9
# 2 10000
# 4 3
# 9 3
# 100 5
# print(arm)
for i in range(n):
res += 1
print(res)
メモ
提出
code: python
n = int(input())
arm = []
for x_l in xl:
arm.append((x_l0 - x_l1, x_l0 + x_l1)) arm = sorted(arm, key=lambda x: x1) # 被ってる数を累積していきたい
for i, v in enumerate(arm):